package tests.user;

import tester.*;

/**
 * Copyright 2007, 2008 Viera K. Proulx
 * This program is distributed under the terms of the 
 * GNU Lesser General Public License (LGPL)
 */

/**
 * The initial tests for the same comparison in the 
 * <CODE>{@link Inspector}</CODE> class.
 * 
 * @author Viera K. Proulx
 * @since 2 June 2007
 */
public class AListTest { 
  public AListTest () {}

  /**
   * Define the needed data and run the sample tests
   */
  public boolean testsToRun(Tester t){ 

    // Authors, Books,  and Songs
    /** sample authors */
    Author author1=new Author("author1",40);
    Author author2=new Author("author2",55);
    Author author3=new Author("author3",66);
    Author author4=new Author("author4",26);

    /** sample books */
    Book book1=new Book("title1",author1,4000); 
    Book book2=new Book("title2",author2,4000);
    Book book3=new Book("title3",author3,3001);
    Book book4=new Book("title4",author4,4000);
    
    /** sample songs */
    Song song1=new Song("title1",4);
    Song song2=new Song("title2",5);
    Song song3=new Song("title3",6);
    Song song1a=new Song("title1",4);

    /** an empty list of books */
    AList<Book> mtBook= new MTList<Book>();
    /** an empty list of songs */
    AList<Song> mtSong= new MTList<Song>();

    /** a list of books */
    AList<Book> booklist= new ConsList<Book>(book1, 
        new ConsList<Book>(book2,
            new ConsList<Book>(book3, 
                mtBook))); 
    
    /** a list of songs */
    AList<Song> songlist= new ConsList<Song>(song1, 
        new ConsList<Song>(song2,
            new ConsList<Song>(song3, 
                mtSong)));
    
    /** a list of songs with the same data*/
    AList<Song> songlist2= new ConsList<Song>(song1a, 
        new ConsList<Song>(song2,
            new ConsList<Song>(song3, 
                mtSong)));

    /** a list of songs with different data*/
    AList<Song> songlist3= new ConsList<Song>(song1, 
        new ConsList<Song>(song2,
            mtSong));

    Inspector insp = new Inspector();
    //tests (incomplete)
    return t.checkExpect(song1, song1, "same songs 1") &&
           t.checkExpect(insp.isSame(song2, song1), 
               false, "same songs 2") &&
           t.checkExpect(song1a, song1, "same songs 3") &&

           t.checkExpect(songlist, songlist2, "same songlists 1") &&
           t.checkExpect(insp.isSame(songlist, songlist3), 
               false, "same songlists 2") &&
           t.checkExpect(insp.isSame(songlist3, songlist2), 
               false, "same songlists 3") &&
           t.checkExpect(insp.isSame(songlist, booklist), 
               false, "same songlists 4") &&

           t.checkExpect(songlist.contains(song1), 
               true, "songlist contains 1") &&
           t.checkExpect(booklist.contains(book4), 
               false, "songlist contains 2");
  } 

} 
